﻿
-- ================================================
-- Remarks: Not part of standard Stored Proc
-- ================================================
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'Ivy_User_GetByLoginID')
	BEGIN
		DROP  Procedure  Ivy_User_GetByLoginID
	END

GO

CREATE PROCEDURE [Ivy_User_GetByLoginID] 
-- =============================================
-- Author:		<Andre Lashley>
-- Create date: <01/03/2011>
-- Description:	<Ivy_User_GetByLoginID>
-- =============================================
-- Add the parameters for the stored procedure here
	(
				@UserLoginID varchar(50),
				@Sys_OrganizationID int = NULL
				
	)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT OFF;

	SELECT	[UserKey],
			[UserLoginID],
			[UserPassword],
			[UserFirstName],
			[UserLastName],
			[UserPrimaryEmailID],
			[UserVerificationCode],
			[UserIsVerified],
			[Sys_DateOfCreation],
			[Sys_DateOfModification],
			[Sys_CreatedByID],
			[Sys_ModifiedByID],
			[Sys_DeleteType],
			[Sys_IsDeleted],
			[Sys_OrganizationID],
			[Sys_InitialPrimaryKeys],
			[Sys_WorkstationName]
	FROM	[User]
	WHERE		
		(
			[UserLoginID] = @UserLoginID AND 
			[Sys_OrganizationID] = ISNULL( @Sys_OrganizationID, [Sys_OrganizationID] )
		);
END
GO
